// pages/mytest/mytest.js
const app = getApp()
import http from "../../utils/http"
import util from "../../utils/util"
Page({

  /**
   * 页面的初始数据
   */
  data: {
    safeTop: `40px`,
    info: '',
    config: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    const high = app.globalData.safeTop + 20
    this.setData({
      safeTop: `${high}px`
    })
    
  },
    /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    this.getInfo();
  },
  onLoadConfig(option){
    this.setData({
      config: app.globalData.config
    })
  },
  toService(){
    wx.navigateToMiniProgram({
      appId: 'wxc2e2e6963f516a2b',
      envVersion: 'develop'
    })
  },
  toShop(){
    wx.navigateToMiniProgram({
      appId: 'wxc71bf1affdb7c8e5',
      envVersion: 'develop'
    })
  },
  login(){
    util.skip('/service/login/login')
  },
  skip(e){
    let url = e.currentTarget.dataset.url
    util.authSkip(url)
  },
  myOrder(e){
    let type = e.currentTarget.dataset.type
    let active = e.currentTarget.dataset.active
    let num = this.data.info ? this.data.info.orderCount.unServiceCount : 0
    util.authSkip('/service/myorder/myorder?type='+type+'&active='+active+'&num='+num)
  },
  getInfo(){
    if(!wx.getStorageSync('token')) return
    http.post('index/userindex', '', !this.data.info).then(res => {
      this.setData({
        info: res.data
      })
    })
  },

  //跳转意见反馈
  tofeedback(){
    wx.navigateTo({
      url: '/service/feedback/feedback',
    })
  },
  //跳转领券中心
  tocouponscenter(){
    wx.navigateTo({
      url: '/service/couponscenter/couponscenter',
    })
  },
  //跳转我的评论
  tomycomment(){
    wx.navigateTo({
      url: '/service/mycomment/mycomment',
    })
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {
    return {}
  }


  
})